package fr.sharpe.app.earthvisualizationproject.model;

import java.util.HashMap;

public class EarthLayer {
	
	private String name;
	private HashMap<String, Object> originalObjects;
	private HashMap<String, Object> convertedObjects;
	private Object type;
	
	public EarthLayer(String name, Object type)
	{
		this.name = name;
		this.type = type;
		this.originalObjects = new HashMap<String, Object>();
		this.convertedObjects = new HashMap<String, Object>();
	}
	
	public boolean containsKey(String key)
	{
		return this.originalObjects.containsKey(key);
	}
	
	public void put(String id, Object original, Object converted)
	{
		this.originalObjects.put(id, original);
		this.convertedObjects.put(id, converted);
	}
	
	public void remove(String id)
	{
		this.originalObjects.remove(id);
		this.convertedObjects.remove(id);
	}
	
	public void update(String id, Object original, Object converted)
	{
		if(this.containsKey(id))
		{//Update
			this.remove(id);
			this.put(id,original,converted);
		}
		else
		{//Add
			this.put(id,original,converted);
		}
	}
	
	public Object findSelectedObject(Object o)
	{
		for(String s:this.convertedObjects.keySet())
		{
			if(this.convertedObjects.get(s).equals(o))
			{
				return this.originalObjects.get(s);
			}
		}
		return null;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Object getType() {
		return type;
	}

	public void setType(Object type) {
		this.type = type;
	}

	public void setOriginalObjects(HashMap<String, Object> originalObjects) {
		this.originalObjects = originalObjects;
	}

	public HashMap<String, Object> getOriginalObjects() {
		return originalObjects;
	}

	public void setConvertedObjects(HashMap<String, Object> convertedObjects) {
		this.convertedObjects = convertedObjects;
	}

	public HashMap<String, Object> getConvertedObjects() {
		return convertedObjects;
	}
	

}
